﻿/*-----------------------------------------------
// File: IconFactory.cs
// Description: 
// Author: Shaobing	492057342@qq.com
-----------------------------------------------*/
using UnityEngine;
using System.Collections;

namespace UI
{
    public class IconFactory : MonoBehaviour
    {
        public GameObject itemIconPrefab;
        public GameObject heroIconPrefab;
        public GameObject heroFragIconPrefab;
        public GameObject equipOrTreaIconPrefab;
        public GameObject equipOrTreaFragIconPrefab;


        public GameObject BuildIcon(string id) {
            if (id.StartsWith(Dict.Config.TableConst.item))
            {
                return GameObject.Instantiate(itemIconPrefab) as GameObject;
            }
            else if (id.StartsWith(Dict.Config.TableConst.war))
            {
                return GameObject.Instantiate(heroIconPrefab) as GameObject;
            }
            else if (id.StartsWith(Dict.Config.TableConst.frag_war))
            {
                return GameObject.Instantiate(heroFragIconPrefab) as GameObject;
            }
            else if (id.StartsWith(Dict.Config.TableConst.equip) || id.StartsWith(Dict.Config.TableConst.trea))
            {
                return GameObject.Instantiate(equipOrTreaIconPrefab) as GameObject;
            }
            else if (id.StartsWith(Dict.Config.TableConst.frag_equip) || id.StartsWith(Dict.Config.TableConst.frag_trea))
            {
                return GameObject.Instantiate(equipOrTreaFragIconPrefab) as GameObject;
            }
            else {
                return null;
            }
        } 

    }
}
